<?php

namespace app\yue\admin;

use app\common\builder\ZBuilder;

class Member extends Common
{
    public function index()
    {
        $map       = $this->getMap();
        $order     = $this->getOrder('id desc');
        $data_list = model('yue_member')->where($map)->order($order)->paginate(10);
        
        // 分页数据
        return ZBuilder::make('table')
            ->setSearch(['id', 'nickName', 'rank', 'score']) // 设置搜索参数
            ->addTimeFilter('create_time')
            ->addFilter('rank', config('yue_rank'))
            ->addOrder('id,rank,score,win,lose') // 添加排序
            ->addColumns([ // 批量添加列
                ['id', 'ID'],
                ['avatarUrl', '头像', 'img_url'],
                ['nickName', '昵称'],
                ['rank', '段位', 'select', config('yue_rank')],
                ['score', '积分'],
                ['win', '胜'],
                ['lose', '负'],
                ['create_time', '加入时间', 'datetime'],
                // ['status', '状态', 'switch'],
            ])
            ->addTopButtons(['enable', 'disable', 'delete']) // 批量添加顶部按钮
            ->setRowList($data_list) // 设置表格数据
            ->fetch(); // 渲染页面
    }
}
